﻿AB.namespace("BD_ProdCate.Mgr");
BD_ProdCate.Mgr = {
    commandHandler: function (command, record) {
        var FId = record.data.FID;
        switch (command) {
            case "Edit":
                FIdH.setValue(FId);
                PordCateEidtStore.load();
                break;
            case "Delete":
                Ext.Msg.confirm('提示', '确定要删除该记录吗?', function (btn) {
                    if (btn == "yes") {
                        Ext.Ajax.request({
                            url: "/ProdCategory/DeleteCategory",
                            method: 'post',
                            params: {
                                FId: FId
                            },
                            success: function (result) {
                                if (!isTimeOut(result)) {
                                    var response = Ext.util.JSON.decode(result.responseText);
                                    if (response.success == false) {
                                        ajaxFailureHandler(response);
                                    } else {
                                        ProdCateListStore.reload();
                                        EditFormPanel.form.reset();
                                        FIdH.setValue(null);
                                        alert("数据删除成功！");
                                    }
                                }
                            }
                        });
                    }
                });
                break;
        }
    },
    successHandler: function (form, action) {
        if (!isTimeOut(action.response)) {
            ProdCateListStore.reload();
            FIdH.setValue(action.result.extraParams.msg);
            PordCateEidtStore.load();
            alert("数据保存成功！");
        }
    },
    failureHandler: function (form, action, failureCallback) {
        failureHandler(form, action);
    },
    successCallback: function () {
    },
    failureCallback: function () {
    },
    formStoreLoaded: function (store, records) {
        var formObj = Ext.getCmp("EditFormPanel");
        formStoreLoaded(store, records, formObj);
    },
    searchList: function () {
        ProdCateListStore.reload();
    },

    resetSearchFrom: function () {
        var formObj = Ext.getCmp("SearchFormPanel");
        formObj.reset();
    }
}